﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Control_ShowCustomer : System.Web.UI.UserControl
{
    ListAndProcessData wsv = new ListAndProcessData();
    private string employeeName = null;
    private string email = null;
    private string check = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        employeeName = Request.QueryString["seach"];
        email = Request.QueryString["email"];
        check = Request.QueryString["Loi"];
        try
        {
            if (check == "404")
            {
                lblnull.Visible = true;
            }
            else
            {
                var content = wsv.searchEmployee(employeeName, email);
                if (content.Count != 0)
                {
                    ListView1.DataSource = content;
                    ListView1.DataBind();
                }
                else
                {

                    Response.Redirect("Employee_Admin.aspx?Loi=404");
                }
            }
        }
        catch (Exception)
        {
            ListView1.DataSource = wsv.getAllEmployee();
            ListView1.DataBind();
        }
    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        if (check == "404")
        {
            Response.Redirect("Employee_Admin.aspx");
        }
        else
        {
            Response.Redirect("Employee_Admin.aspx?seach=" + txtEmployeeName.Text + "&email=" + txtEmail.Text);
        }
    }
}